package com.wb.iec104.analysis;

import lombok.Data;

import java.text.SimpleDateFormat;

/**
 * 数据处理解析类
 *
 * @author HR
 */
@Data
public class Bean {
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
    private static SimpleDateFormat sdf_second = new SimpleDateFormat("0s");
    private String bid;
    private Integer addr;
    private String mtype;
    //private String type_desc;
    //品质
    private int dqs;
    private String dqsDesc;
    //private String short_data;
    //private String state ;
    private String data_time;
    private long costs;
    private  int port;
    private String station_name;

    private String description;

    private String point_code;

    private String value;

    private String timeStr;

    public Bean() {
    }

    /**
     * 带时标的浮点类型
     *
     * @param addr
     * @param dqs
     * @param short_data
     */
    public Bean(Integer addr, int dqs, String short_data,String dataTime,long cost) {
        this.addr = addr;
        this.mtype = "M_ME_TF_1";
        if(dqs!=0||dqs!=1){
            this.dqs = 0;
        }else{
            this.dqs = dqs;
        }
        //this.type_desc = "带CP56Time2a时标的测量值,短浮点数";
        this.value = short_data;
        this.data_time=dataTime;
        this.costs=cost;
        //this.port= PropertiesUtils.LISTEN_PORT;
        //this.station_name=PropertiesUtils.STATION_NAME;
    }

    /**
     * 不带带时标的浮点类型
     *
     * @param addr
     * @param dqs
     * @param short_data
     */
    public Bean(Integer addr, int dqs, String short_data,String dataTime) {
        this.addr = addr;
        this.mtype = "M_ME_TF_1";
        if(dqs!=0||dqs!=1){
            this.dqs = 0;
        }else{
            this.dqs = dqs;
        }
        //this.type_desc = "带CP56Time2a时标的测量值,短浮点数";
        this.value = short_data;
        this.data_time=dataTime;
        //this.port= PropertiesUtils.LISTEN_PORT;
       // this.station_name=PropertiesUtils.STATION_NAME;
    }

    /**
     * 带CP56Time2a时标的单点信息
     *
     * @param addr
     * @param dqs
     */
    public Bean(Integer addr, int dqs,String dataTime,long cost) {
        this.addr = addr;
        this.mtype = "M_SP_TB_1";
        this.dqs = dqs;
        //this.type_desc = "带CP56Time2a时标的单点信息";
        this.value = 1==dqs ? "合" : "分";
        this.data_time=dataTime;
        this.costs=cost;
        //this.port= PropertiesUtils.LISTEN_PORT;
        //this.station_name=PropertiesUtils.STATION_NAME;
    }

    /**
     * 不带带CP56Time2a时标的单点信息
     *
     * @param addr
     * @param dqs
     */
    public Bean(Integer addr, int dqs,String dataTime) {
        this.addr = addr;
        this.mtype = "M_SP_NA_1";
        this.dqs = dqs;
        this.value = 0==dqs ? "分" : "合";
        this.data_time=dataTime;
        //this.port= PropertiesUtils.LISTEN_PORT;
        //this.station_name=PropertiesUtils.STATION_NAME;
    }

    /**
     * 不带带CP56Time2a时标的单点信息
     *
     * @param addr
     */
    public Bean(Integer addr, String dataTime,String short_data) {
        this.addr = addr;
        this.mtype = "M_ME_ND_1";
        this.data_time=dataTime;
        this.value=short_data;
       // this.port= PropertiesUtils.LISTEN_PORT;
       // this.station_name=PropertiesUtils.STATION_NAME;
    }


    public Bean(int tempAddr, int qds) {
        this.addr = tempAddr;
        this.dqs=qds;
    }
}
